package cn.edu.thu.laud.thrift.service;

import java.util.HashMap;
import java.util.Map;
import java.util.Random;

import org.apache.cassandra.service.ClientState;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class LaUDClientState extends ClientState{
	boolean locked=false;
	private Logger logger=LoggerFactory.getLogger(LaUDClientState.class);
	public Random random=new Random(System.currentTimeMillis());
	public LaUDClientState(){
		super();
	}
	/**
	 * key: check code
	 * value: the location of fs
	 */
	private Map<String, ServiceFileInfo>fileDataSchedule=new HashMap<String, ServiceFileInfo>();
	private Map<String, String> fileDataScheduleResult=new HashMap<String, String>();
	private String sessionId;
	public Map<String, ServiceFileInfo> getFileDataSchedule() {
		return fileDataSchedule;
	}
	public void addFileDataSchedule(String key,ServiceFileInfo fileInfo){
		//logger.debug("add fileDataSchedule:"+fileDataSchedule.size());
		fileDataSchedule.put(key, fileInfo);
	}
	public void addFileDataScheduleResult(String key,String result){
		//logger.debug("add FileDataScheduleResult:"+fileDataScheduleResult.size());
		fileDataScheduleResult.put(key, result);
	}	
	public ServiceFileInfo getFileInfo(String checkCode) {
		return fileDataSchedule.get(checkCode);
	}
	public void removeFileDataSchedule(String key){
		//logger.debug("remove FileDataSchedule:"+fileDataSchedule.size());
		fileDataSchedule.remove(key);
	}
	public void clearFileDataSchedule(){
		fileDataSchedule.clear();
	}
	public void clearFileDataScheDuleResult(){
		fileDataScheduleResult.clear();
	}
	public void removeFileDataScheduleResult(String key){
		//logger.debug("remove FileDataScheduleResult:"+fileDataScheduleResult.size());
		fileDataScheduleResult.remove(key);
	}
	public void setLocked(boolean b) {
		this.locked=b;
	}
	public Map<String, String> getFileDataScheduleResult() {
		return fileDataScheduleResult;
	}
	public void setFileDataScheduleResult(Map<String, String> fileDataScheduleResult) {
		this.fileDataScheduleResult = fileDataScheduleResult;
	}
	public void setSessionId(String string) {
		this.sessionId=string;
	}
	public String getSessionId(){
		return this.sessionId;
	}
	public String getCheckCode() {
		return ""+System.currentTimeMillis()+random.nextInt();
	}
	
	
}
